//
//  OKSelectBtn.m
//  fast
//
//  Created by answer on 16/5/21.
//  Copyright © 2016年 answer. All rights reserved.
//

#import "OKSelectBtn.h"
#import <Masonry/Masonry.h>

@interface OKSelectBtn ()
@property (strong, nonatomic) UIImageView *iconView;
@property (strong, nonatomic) UIView *cuttingLine;
@end
@implementation OKSelectBtn

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.layer.cornerRadius = 5;
    self.backgroundColor = [UIColor whiteColor];
    [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    self.titleLabel.font = [UIFont systemFontOfSize:14];
//    self.titleLabel.textAlignment = NSTextAlignmentLeft;
    self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    self.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
    
    [self addSubview:self.iconView];
    [self addSubview:self.cuttingLine];
    [self.iconView bringSubviewToFront:self];
    
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.centerX.equalTo(self.mas_right).offset(-16);
        make.width.equalTo(@5);
        make.height.equalTo(@10);
    }];
    
    [self.cuttingLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(5);
        make.bottom.equalTo(self).offset(-5);
        make.right.equalTo(self).offset(-32);
        make.width.equalTo(@1);
    }];
    
}

- (UIImageView *)iconView {
//    if (_iconView == nil) {
//        _iconView = [[UIButton alloc] init];
//        [_iconView setImage:[UIImage imageNamed:@"position-right"] forState:UIControlStateNormal];
//    }
//    return _iconView;
    if (_iconView == nil) {
        _iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"position-right"]];
        //_iconView.bounds = CGRectMake(0, 0, 10, 10);
    }
    return _iconView;
}

- (UIView *)cuttingLine {
    if (_cuttingLine == nil) {
        _cuttingLine = [[UIView alloc] init];
        _cuttingLine.backgroundColor = [UIColor lightGrayColor];
    }
    return _cuttingLine;
}

@end
